home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9400 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  71 lines

  1. Newsgroups: comp.lang.c
  2. Path: peer-news.britain.eu.net!info!grace!eegibbon
  3. From: eegibbon@grace (Matthew Gibbons)
  4. Subject: Re: Division problem
  5. X-Nntp-Posting-Host: grace.swan.ac.uk
  6. Message-ID: <Do3GrH.n27@info.swan.ac.uk>
  7. Sender: news@info.swan.ac.uk
  8. Organization: Swansea News Server
  9. X-Newsreader: TIN [version 1.2 PL2]
  10. References: <3141571F.41C67EA6@swansea.ac.uk>
  11. Date: Mon, 11 Mar 1996 08:26:05 GMT
  12.  
  13. Matthew Gibbons (m.h.gibbons@swansea.ac.uk) wrote:
  14. : Hi,
  15.  
  16. : I have a little problem that I can't seem to solve. Any help would be
  17. : greatly appreciated...
  18.  
  19. : I have a 64 bit number (grabbed from an external clock source) which
  20. : I need to be able to divide by a given factor, replacing the original
  21. : number with the quotient, and returning the remainder.
  22.  
  23. : The 64 bit number is of this type:
  24.  
  25. :     typedef struct {
  26. :         unsigned char ssr[8];
  27. :         } gtime_t;
  28.  
  29. : The MSB of this number being ssr[7].
  30.  
  31. : I want to be able to call a function, say 'divgtime', thus:
  32.  
  33. :     gtime_t   gt;
  34. :     unsigned  rem;
  35.  
  36. :     :
  37.  
  38. :     // divide the time by 1000
  39. :     rem = divgtime(>, 1000);
  40.  
  41. :     :
  42.  
  43. : Where 1000 is the desired factor.
  44.  
  45. : I have tried lots of ways of doing this division, but to no avail.
  46.  
  47. : Can anyone help me? If you can, please could you email me, as my news
  48. : link is very slow in updating.
  49.  
  50. : Thanks in advance,
  51. : Matthew
  52.  
  53.  
  54. Peter Kohlberger (acorn@warwick.net) pointed out that I neglected to mention
  55. the data format of the 64-bit number. Oops.
  56.  
  57. The number is a 64-bit unsigned integer, which is broken into 8 bytes. The
  58. number actually represents the time in nanoseconds.
  59.  
  60. If ssr was { 12, 1, 0, 0, 0, 0, 0, 0 } then the number would represent 278.
  61.  
  62. I hope this helps.
  63.  
  64. Cheers,
  65. Matthew
  66.  
  67. --
  68.  
  69. 110000001111111111101110 anyone?
  70.  
  71.